import redis
import logging


class Config(object):
    DEBUG = True
    # 链接数据
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@localhost/pythonlove'
    # 动态追踪
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    #在请求结束之前，自动提交数据库修改
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    # 设置redis对象参数的变量
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    # 设置秘钥
    SECRET_KEY = '72SFtpin5UbceopOPq+qiRcLOqJhmq2vL+2fDqUb7q8='
    # 配置ｆｌａｓｋ－ｓｅｓｓｉｏｎ拓展
    SESSION_TYPE = 'redis'
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    SESSION_USE_SIGNER = True # 开启签名，保护数据安全
    PERMANENT_SESSION_LIFETIME = 86400 * 7  # 配置过期时间


class DevelopmentConfig(Config):
    """开发模式下的配置"""
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    """生产模式下的配置"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING


